package com.xbongbong.paas.domain.entity.ext;

import com.alibaba.fastjson.JSONObject;
import com.xbongbong.paas.toolbox.util.DateUtil;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.io.Serializable;

/**
 * 与 paas 持久层 entity PaasFormDataEntity 对应的 ES 实体
 *   备注：atformId中的F没有大写，因为at|bt|ct  是要灵活拼装的，避免了字符的转换
 * @see com.xbongbong.paas.domain.entity.PaasFormDataEntity
 * @author kaka
 * @time 2018-9-17 17:02
 */
@Getter
@Setter
@ToString
public class StatisticPaasFormDataEsEntity implements Serializable{

    private static final long serialVersionUID = -7024828724863824665L;
    /**
     *主键id
     */
    private String id;
    /**
     * esId
     */
    private String esId;
    /**
     * 数据源id
     */
    private Long warehouseId;
    /**
     *
     */
    private String uesId;

    /**
     * 规则id(唯一确定一张表)
     */
    private Long ruleId;

    /**
     * 公司id
     */
    private String corpid;

    /**
     * 创建者id
     */
    private String creatorId;
    /**
     * 创建时间时间戳
     */
    private Long addTime;
    /**
     * 更新时间时间戳
     */
    private Long updateTime;
    /**
     * 删除标记
     */
    private Integer del;
    /**
     * 主键 对应 PaasFormDataEntity 的 id
     * @see com.xbongbong.paas.domain.entity.PaasFormDataEntity #id
     */
    private Long atdataId;
    /**
     * 应用id
     */
    private Long atappId;

    /**
     * 菜单id
     */
    private Long atmenuId;
    /**
     * 表单id
     */
    private Long atformId;

    /**
     * 编号
     */
    private String atserialNo;
    /**
     * 拥有者id
     */
    private String atownerId;
    /**
     * 部门id
     */
    private Long atdepartmentId;
    /**
     * 流程状态枚举值
     */
    private Integer atflowStatus;
    /**
     * 当前流程节点id
     */
    private Long atcurrentFlowNode;
    /**
     * 当前流程节点负责人
     */
    private String atcurrentFlowNodeOwner;
    /**
     * 表单数据存储json，mysql 5.7 开始支持该格式，并支持检索
     */
    private JSONObject atdata;
    /**
     * 创建者id
     */
    private String atcreatorId;
    /**
     * 创建时间时间戳
     */
    private Long ataddTime;
    /**
     * 更新时间时间戳
     */
    private Long atupdateTime;
    /**
     * 删除标记
     */
    private Integer atdel;
    /**
     * 主键 对应 PaasFormDataEntity 的 id
     * @see com.xbongbong.paas.domain.entity.PaasFormDataEntity # id
     */
    private Long btdataId;
    /**
     * 应用id
     */
    private Long btappId;

    /**
     * 菜单id
     */
    private Long btmenuId;
    /**
     * 表单id
     */
    private Long btformId;

    /**
     * 编号
     */
    private String btserialNo;
    /**
     * 拥有者id
     */
    private String btownerId;
    /**
     * 部门id
     */
    private Long btdepartmentId;
    /**
     * 流程状态枚举值
     */
    private Integer btflowStatus;
    /**
     * 当前流程节点id
     */
    private Long btcurrentFlowNode;
    /**
     * 当前流程节点负责人
     */
    private String btcurrentFlowNodeOwner;
    /**
     * 表单数据存储json，mysql 5.7 开始支持该格式，并支持检索
     */
    private JSONObject btdata;
    /**
     * 创建者id
     */
    private String btcreatorId;
    /**
     * 创建时间时间戳
     */
    private Long btaddTime;
    /**
     * 更新时间时间戳
     */
    private Long btupdateTime;
    /**
     * 删除标记
     */
    private Integer btdel;
    /**
     * 主键 对应 PaasFormDataEntity 的 id
     * @see com.xbongbong.paas.domain.entity.PaasFormDataEntity # id
     */
    private Long ctdataId;
    /**
     * 应用id
     */
    private Long ctappId;

    /**
     * 菜单id
     */
    private Long ctmenuId;
    /**
     * 表单id
     */
    private Long ctformId;

    /**
     * 编号
     */
    private String ctserialNo;
    /**
     * 拥有者id
     */
    private String ctownerId;
    /**
     * 部门id
     */
    private Long ctdepartmentId;
    /**
     * 流程状态枚举值
     */
    private Integer ctflowStatus;
    /**
     * 当前流程节点id
     */
    private Long ctcurrentFlowNode;
    /**
     * 当前流程节点负责人
     */
    private String ctcurrentFlowNodeOwner;
    /**
     * 表单数据存储json，mysql 5.7 开始支持该格式，并支持检索
     */
    private JSONObject ctdata;
    /**
     * 创建者id
     */
    private String ctcreatorId;
    /**
     * 创建时间时间戳
     */
    private Long ctaddTime;
    /**
     * 更新时间时间戳
     */
    private Long ctupdateTime;
    /**
     * 删除标记
     */
    private Integer ctdel;

    private Integer atalone;
    private Integer btalone;
    private Integer ctalone;

    public StatisticPaasFormDataEsEntity(){
        del = 0;
        long now = DateUtil.getInt();
        updateTime = now;
    }

    /**
     * 设置A表的数据（A作为驱动表）
     * @param entity
     */
    public void putAtEntity(PaasFormDataEntityExt entity) {
        if (entity == null) {
            return;
        }
        this.atdataId = entity.getId();
        this.atappId = entity.getAppId();
        this.atmenuId = entity.getMenuId();
        this.atformId = entity.getFormId();
        this.atserialNo = entity.getSerialNo();
        this.atownerId = entity.getOwnerId();
        this.atdepartmentId = entity.getDepartmentId();
        this.atflowStatus = entity.getFlowStatus();
        this.atdata =  entity.getData();
        this.atcreatorId = entity.getCreatorId();
        this.ataddTime = entity.getAddTime();
        this.atupdateTime = entity.getUpdateTime();
        this.atdel = entity.getDel();
        this.atalone = entity.getAlone();
    }

    public void putBtEntity(PaasFormDataEntityExt entity) {
        if (entity == null) {
            return;
        }
        this.btdataId = entity.getId();
        this.btappId = entity.getAppId();
        this.btmenuId = entity.getMenuId();
        this.btformId = entity.getFormId();
        this.btserialNo = entity.getSerialNo();
        this.btownerId = entity.getOwnerId();
        this.btdepartmentId = entity.getDepartmentId();
        this.btflowStatus = entity.getFlowStatus();
        this.btdata =  entity.getData();
        this.btcreatorId = entity.getCreatorId();
        this.btaddTime = entity.getAddTime();
        this.btupdateTime = entity.getUpdateTime();
        this.btdel = entity.getDel();
        this.btalone = entity.getAlone();
    }

    public void putCtEntity(PaasFormDataEntityExt entity) {
        if (entity == null) {
            return;
        }
        this.ctdataId = entity.getDataId();
        this.ctappId = entity.getAppId();
        this.ctmenuId = entity.getMenuId();
        this.ctformId = entity.getFormId();
        this.ctserialNo = entity.getSerialNo();
        this.ctownerId = entity.getOwnerId();
        this.ctdepartmentId = entity.getDepartmentId();
        this.ctflowStatus = entity.getFlowStatus();
        this.ctdata =  entity.getData();
        this.ctcreatorId = entity.getCreatorId();
        this.ctaddTime = entity.getAddTime();
        this.ctupdateTime = entity.getUpdateTime();
        this.ctdel = entity.getDel();
        this.ctalone = entity.getAlone();
    }
}
